<template>
  <div class="container">
    <div class="beginner">
      <div class="banner row">
        <div class="center">
          <div>
            <h1>Hi, 欢迎来到互联门户系统</h1>
            <a href="http://10.10.0.44:8100/home" target="_blank" class="next-btn next-medium next-btn-primary">
              <el-button type="primary">开始使用</el-button>
            </a>
          </div>
        </div>
      </div>
      <div class="bests row">
        <div class="center">
          <div class="best" v-for="(item, index) in bestsList" :key="index">
            <div class="title">{{item.title}}</div>
            <div class="desc">{{item.desc}}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="content">
      <div class="center">
        <!-- 引导 -->
        <div class="guide next-card">
          <div class="header">
            <div class="title">引导</div>
            <div class="actions">
              <el-button link type="primary" class="jump" @click="handleJump">跳过引导任务，查看我的资源
                <i class="iconfont">&#xe645;</i>
              </el-button>
            </div>
          </div>
          <div class="guide-content">
            <div class="progress">
              <div class="label">
                <span>已完成 
                  <span style="color:#0064c8;">{{hasFinishedStep}}</span>
                  /{{steps.length}} 个任务
                </span>
              </div>
              <div class="bar">
                <el-progress :show-text="false" :percentage="hasFinishedStep * 100 / steps.length"/>
              </div>
            </div>
            <div class="steps">
              <div class="tabs">
                <div class="tab" :class="curStep == index ? 'active':''" v-for="(item, index) in steps" :key="index" @click="handleStepIndexClick(item,index)">
                  <div class="title">{{item.title}}</div>
                  <div class="status">
                    <el-icon v-if="item.status == 1"><CircleCheckFilled /></el-icon>
                    <div v-else class="empty"></div>
                  </div> 
                </div>
              </div>
              <div class="steps-content" :style="{
                'background-image': `url(${curStepContent.imgUrl})`
              }">
                <h3>
                  <span class="title">{{curStepContent.title}}</span>
                  <div class="finished" v-if="curStepContent.status == 1">已完成</div>
                </h3>
                <p>{{curStepContent.desc}}</p>
                <el-button class="helpers" :type="curStepContent.status == 1 ? '':'primary'" @click="handleStepClick">{{curStepContent.btnText}}</el-button>
              </div>
              <div class="steps-arrow">
                <div class="btn pre next-card" :class="curStep == 0 ? 'disabled':''" @click="handleStepPre">
                  <i class="iconfont">&#xe645;</i>
                </div>
                <div class="btn next next-card" :class="curStep == steps.length - 1 ? 'disabled':''" @click="handleStepNext">
                  <i class="iconfont">&#xe645;</i>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- 推荐 -->
        <div class="recommend next-card">
          <!-- <div class="header">
            <div class="title">入口</div>
          </div>
          <div class="recommend-content">
          </div> -->
          <ModuleList :curModule="curModule" :rowNum="7"/>
        </div>
        <!-- 帮助 -->
        <div class="help">
          需要帮助？
          <a href="">联系我们</a>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { computed, ref, toRefs } from 'vue'
import { CircleCheckFilled } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import ModuleList from '@/views/home/components/ModuleList.vue'

const props = defineProps({
  curModule: {
    type: Object,
    default: () => {}
  },
  LandingPage: {
    type: Boolean,
    default: false
  }
})
const emits = defineEmits(['update:LandingPage'])
const { curModule } = toRefs(props)

const bestsList = ref([
  {
    title: '业界领先的技术能力',
    desc: '提供强大的集成扩展，集约化微服务架构'
  },
  {
    title: '稳定可靠的产品服务',
    desc: '高性能运行，持续更新与支持'
  },
  {
    title: '快捷方便的协作能力',
    desc: '任务分配、进度跟踪，审核流程'
  },
  {
    title: '高效安全的管理',
    desc: '精细化权限控制，全面的日志审计'
  }
])
const steps = ref([
  { title: '实名认证', status: 1, btnText: '去修改', imgUrl: 'http://foxhcs-alpha.foxtest.net/oss/20240926/111124977.png', desc: '使用唯一的手机号作为绑定登录账号，此项是任务必备完善' },
  { title: '账号安全设置', status: 1, btnText: '去修改', imgUrl: 'http://foxhcs-alpha.foxtest.net/oss/20240926/111124559.png', desc: '为账号设置登录安全配置，提高账号的安全水平，降低被盗用的风险' },
  { title: '订阅与推送', status: 0, btnText: '去创建', imgUrl: 'http://foxhcs-alpha.foxtest.net/oss/20240926/111124303.png', desc: '提供多种推送方式可以更好地满足不同用户的需求。' },
  { title: '开始使用', status: 0, btnText: '立即使用', imgUrl: 'http://foxhcs-alpha.foxtest.net/oss/20240926/111124221.png', desc: '互联门户系统提供了一个全面的生态系统，不仅能够增强用户体验，还能促进用户粘性和业务增长' },
])
const curStep = ref(1)
const curStepContent = computed(()=>{return steps.value[curStep.value]})
const hasFinishedStep = ref(steps.value.filter(item => item.status == 1).length)
const handleStepIndexClick = (item, index) => {
  curStep.value = index
}
const handleStepClick = () => {
  ElMessage({
    showClose: true,
    message: '暂无权限',
    type: 'warning',
  })
}
const handleStepPre = () => {
  if(curStep.value > 0) curStep.value--
}
const handleStepNext = () => {
  if(curStep.value < steps.value.length - 1) curStep.value++
}
const handleJump = () => {
  emits('update:LandingPage', false)
}
</script>
<style scoped lang='scss'>
.container{
  .beginner{
    .banner{
      background-image: url('~@/assets/homeBanner/1.jpg');
      background-position: top;
      background-repeat: no-repeat;
      background-size: cover;
      height: 180px;
      background-color: #fff;
      display: flex;
      justify-content: center;
      padding: 0 16px;
      .center{
        -webkit-box-flex: 0;
        -webkit-flex: 0 1 1390px;
        -moz-box-flex: 0;
        -ms-flex: 0 1 1390px;
        flex: 0 1 1390px;
        margin: 0 24px;
        h1{
          color: #333;
          font-size: 32px;
          line-height: 40px;
          margin: 40px 0 20px;
          font-weight: 500;
        }
      }
    }
    .bests {
      background-color: #fff;
      display: flex;
      justify-content: center;
      padding: 0 16px;
      -webkit-box-shadow: inset 0 -1px 0 0 #e5e5e5, inset 0 1px 0 0 #e5e5e5;
      box-shadow: inset 0 -1px 0 0 #e5e5e5, inset 0 1px 0 0 #e5e5e5;
      .center{
        display: flex;
        justify-content: space-between;
        flex: 0 1 1390px;
        margin: 0 24px;
        .best {
          padding: 12px 0;
          width: 220px;
          .title {
            font-weight: 500;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
          .desc {
            color: #555;
            line-height: 20px;
          }
        }
      }
    }
  }
  .content{
    display: flex;
    justify-content: center;
    .center{
      display: flex;
      flex-direction: column;
      flex: 0 1 1390px;
      margin: 0 24px;
      .guide{
        margin-top: 16px;
        padding: 16px;
        .header{
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 16px;
          .title{
            font-size: 14px;
            font-weight: 500;
            line-height: 22px;
          }
          .actions{
            .jump{
              display: flex;
              align-items: center;
              i{
                font-size: 12px;
                margin-left: 10px;
              }
            }
          }
        }
        .guide-content{
          .progress{
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
            .label{
              width: 210px;
            }
            .bar{
              flex: 1;
              ::v-deep(.el-progress-bar__outer){
                height: 4px !important;
              }
            }
          }
          .steps{
            display: flex;
            box-sizing: border-box;
            .tabs{
              display: block;
              flex: 0 1 auto;
              color: #333;
              justify-content: space-between;
              .tab{
                display: flex;
                justify-content: space-between;
                align-items: center;
                border-left: 2px solid #e5e5e5;
                cursor: pointer;
                font-weight: 500;
                height: auto;
                line-height: 20px;
                margin-bottom: 3px;
                min-height: 40px;
                padding: 10px 0 10px 22px;
                transition: all .3s ease;
                width: 194px;
                box-sizing: border-box;
                &:hover{
                  background-color: #fbfbfb;
                  border-color: #0064c8;
                  color: #0064c8;
                }
                .status{
                  .el-icon{
                    font-size: 16px;
                    color: $mainColor;
                  }
                  .empty {
                    border: 1px solid #e5e5e5;
                    border-radius: 14px;
                    display: inline-block;
                    height: 14px;
                    transform: translateY(3px);
                    width: 14px;
                    box-sizing: border-box;
                  }
                }
              }
              .tab.active{
                background-color: #fbfbfb;
                border-color: #0064c8;
                color: #0064c8;
              }
            }
            .steps-content{
              background-color: #fbfbfb;
              border: 1px solid #e5e5e5;
              border-radius: 2px;
              flex: 1;
              height: auto;
              margin: 0 9px 0 16px;
              padding: 24px 28px;
              background-position: 100% 100%;
              background-repeat: no-repeat;
              background-size: 330px auto;
              position: relative;
              h3{
                color: #333;
                font-size: 20px;
                font-weight: 500;
                line-height: 30px;
                margin: 0;
               .finished{
                background-color: #eee;
                border-radius: 2px;
                color: #969696;
                display: inline-block;
                font-weight: 400;
                line-height: 24px;
                margin-left: 12px;
                padding: 0 8px;
                transform: translateY(-2px);
                }
              }
              p{
                color: #555;
                height: auto;
                line-height: 20px;
                margin: 6px 0 48px;
                min-height: 20px;
                width: 60%;
              }
              .helpers {
                bottom: 24px;
                position: absolute;
              }
            }
            .steps-arrow{
              display: flex;
              flex: 0 1 auto;
              flex-direction: column;
              row-gap: 8px;
              .btn{
                border-color: #e5e5e5;
                flex: 1 auto;
                padding: 0;
                width: 32px;
                display: flex;
                justify-content: center;
                align-items: center;
                cursor: pointer;
                user-select: none;
                i{
                  font-size: 12px;
                }
              }
              .pre i{
                transform: rotate(-90deg);
              }
              .next i{
                transform: rotate(90deg);
              }
              .disabled{
                border-color: #e5e5e5;
                cursor: not-allowed;
                opacity:.5;
                background-color: rgb(244, 244, 244);
                box-shadow: none;
              }
            }
          }
        }
      }
      .recommend{
        margin-top: 16px;
        .header{
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 16px;
          .title{
            font-weight: 500;
            line-height: 22px;
          }
        }
        .recommend-content{
          display: flex;
          column-gap: 16px;
          flex-wrap: wrap;
          justify-content: space-between;
          row-gap: 16px;
          background-position: 100% 100%;
          background-repeat: no-repeat;
          background-size: 330px auto;
          position: relative;
          box-sizing: border-box;
        }
      }
      .help{
        color: #555;
        padding: 16px;
        a{
          color: $mainColor;
        }
      }
    }
  }
}
</style>